


//提交数据
$(document).on('click' , '#item_submit_save' , function(e){
		var re = GetRequest();
	var shop = re['shop'];
		var type = $(this).attr('data-type');
	if(type == 'create'){
		//新增提交数据
		var info = {
			timeFrom: $('[name="timeFrom"]').val(),
			timeTo: $('[name="timeTo"]').val(),
			name: $('[name="name"]').val(),
//			maxFreeNum: parseInt($('[name="maxFreeNum"]').val()),
			maxSaleNum: parseInt($('[name="num"]').val()),
			price: parseFloat(1).toFixed(2),
//			lowPrice: parseFloat($('[name="initprice"]').val()).toFixed(2),
//			salePro: parseFloat($('[name="salePro"]').val()).toFixed(2),
			salePrice: parseFloat(1).toFixed(2),
//			saleSettleSum: parseFloat($('[name="saleSettleSum"]').val()).toFixed(2),
//			freeSettleSum: parseFloat($('[name="freeSettleSum"]').val()).toFixed(2),
//			fee: parseFloat($('[name="fee"]').val()).toFixed(2),
			settleSum: parseFloat($('[name="settleSum"]').val()).toFixed(2),
			status: 1,
			shop:parseInt(shop),
			type: "wxadd"
		};
		doPost("shop/addSettletempitem",info,function(data){
				
			if(data.success){
				alert('添加成功');
				
				
				$('#add_item_modal').modal('hide');
				$("#bootstrap-table").bootstrapTable('refresh');
			}
		});
	}
	if(type == 'edit'){
		//编辑提交数据
		var info = {
//			shopTemp: tempid,
			timeFrom: $('[name="timeFrom"]').val(),
			timeTo: $('[name="timeTo"]').val(),
			name: $('[name="name"]').val(),
//			maxFreeNum: parseInt($('[name="maxFreeNum"]').val()),
			maxSaleNum: parseInt($('[name="num"]').val()),
			price: parseFloat($('[name="price"]').val()).toFixed(2),
//			lowPrice: parseFloat($('[name="initprice"]').val()).toFixed(2),
//			salePro: parseFloat($('[name="salePro"]').val()).toFixed(2),
			salePrice: parseFloat($('[name="initprice"]').val()).toFixed(2),
//			saleSettleSum: parseFloat($('[name="saleSettleSum"]').val()).toFixed(2),
//			freeSettleSum: parseFloat($('[name="freeSettleSum"]').val()).toFixed(2),
//			fee: parseFloat($('[name="fee"]').val()).toFixed(2),
			settleSum: parseFloat($('[name="settleSum"]').val()).toFixed(2),
			status: 1,
			type: "wxupdate"
		};
		doPost("shop/addSettletempitem",info,function(data){
			
			if(data.success){
				alert('更新成功');
					settlement() ;
			}
		});
	}
});
    function  settlement() {
    			var re = GetRequest();
	var shop = re['shop'];
       // $.loadInner.updateUrl("/aityWeb/view/venue/details/venue_detail.html");
        // $.loadInner.updateUrl("/aityWeb/view/venue/details/venue_upload.html");
        window.location.href = "/aityWeb/view/venue/details/settlement/list.html?shop="+shop;
//       syslog(JSON.stringify(shop));
//      $.loadInner.updateUrl("/aityWeb/view/venue/details/card.html?shop="+id);
    }
    function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
        	var name = strs[i].split("=")[0];
        	var value = strs[i].split("=")[1];
            //theRequest[name]=unescape(value);
            theRequest[name]=decodeURI(value);
        }
   }
   return theRequest;
};